package com.jie.mapper;

import com.jie.show.FileInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: zxm52
 * Date: 2021/6/23
 * Time: 10:14
 */
public interface FileMapper {

    /**
     * 根据文件MD5查询文件上传记录
     *
     * @param md5
     * @return
     */
    @Select("select * from t_chanson where md5 = #{md5}")
    public FileInfo getFileInfoByMD5(String md5);


    @Select("select * from t_chanson")
    List<FileInfo> getMyInfo();



    /**
     * 保存文件上传记录
     *
     * @param info
     * @return
     */
    @Insert("insert into t_chanson (name, url, path, size, type, md5, account) values " +
            "(#{info.name}, #{info.url}, #{info.path}, #{info.size}, #{info.type}, #{info.md5},#{info.account})")
    public boolean createFileInfo(@Param("info") FileInfo info);

    List<FileInfo> getMyMusic(String name);

    @Delete("delete from t_chanson where id = #{id}")
    int deletes(Integer id);


}
